﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AxialWeb
{
	public partial class Form : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
		}

		public override void Validate()
		{
			base.Validate();
		}

		public override void Validate(string validationGroup)
		{
			base.Validate(validationGroup);
		}

		public bool JSValidate()
		{
			bool noErrors = true;
			if (txtName.Text.Length < 3)
			{
				lblNameError.Text = "The name is too short.";
				lblNameError.Style[HtmlTextWriterStyle.Display] = "";
				noErrors = false;
			}
			else
			{
				lblNameError.Style[HtmlTextWriterStyle.Display] = "none";
			}

			if (txtColor.Text.ToLower() != "blue")
			{
				lblColorError.Style[HtmlTextWriterStyle.Display] = "";
				lblColorError.Text = "No, your favor color is blue.";
				noErrors = false;
			}
			else
			{
				lblColorError.Style[HtmlTextWriterStyle.Display] = "";
			}

			if (noErrors)
				return true;

			return noErrors;
		}

		public void FillDropDown()
		{
			ddlLevel2.Items.Clear();
			if (ddlLevel1.SelectedValue == "1")
			{
				ddlLevel2.Items.Add(new ListItem { Text = "10", Value = "10" });
				ddlLevel2.Items.Add(new ListItem { Text = "11", Value = "11" });
				ddlLevel2.Items.Add(new ListItem { Text = "12", Value = "12" });
			}
			else
			{
				ddlLevel2.Items.Add(new ListItem { Text = "4", Value = "4" });
				ddlLevel2.Items.Add(new ListItem { Text = "5", Value = "5" });
				ddlLevel2.Items.Add(new ListItem { Text = "6", Value = "6" });
			}
		}
	}
}
